package service.impl;

import dao.CommodityDao;
import dao.impl.CommodityDaoImpl;
import entity.Commodity;
import service.CommodityService;

import java.util.List;

public class CommodityServiceImpl implements CommodityService {
    private CommodityDao commodityDao = new CommodityDaoImpl();
    @Override
    public List<Commodity> getAllCommodities() {
        List<Commodity> commodities = commodityDao.selectAllCommodities();
        return commodities;
    }

    @Override
    public List<Commodity> getCommoditiesByType(String type) {
        List<Commodity> commodities = commodityDao.getCommodityByType(type);
        return commodities;
    }

    @Override
    public void addCommodity(Commodity commodity) {
        commodityDao.insertCommodity(commodity);
    }

    @Override
    public List<String> getCommodityTypes() {
        return commodityDao.getAllTypes();
    }

    @Override
    public void deleteCommodityById(int id) {
        commodityDao.deleteCommodityById(id);
    }
}
